%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%% ufpehesis.cls
%%% UFPE Thesis/Dissertation document class
%%% (C) 2003--2005 Paulo Gustavo Soares Fonseca
%%% THIS FILE COMES WITH NO WARRANTIES
%%% PERMISSION TO COPY AND REDISTRIBUTE FREE OF CHARGE
%%% FOR ACADEMIC PURPOSES ONLY
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%    Author              = "Paulo G. S. Fonseca",
%%%    Version             = "0.9.2",
%%%    Date                = "29 Jan 2006",
%%%    Filename            = "ldlthesis.cls",
%%%    Address             = "Universidade Federal de Pernambuco
%%%                           Centro de Informática",
%%%    Telephone           = "+55 81 2126-8430",
%%%    Email               = "paguso@cin.ufpe.br",
%%%    Keywords            = "LaTeX, Thesis, Dissertation",
%%%    Abstract            = "LaTeX document-style for typesetting of
%%%                           Monographs, Theses and Dissertations at the
%%%                           Federal University of Pernambuco - Brazil"
%%%    SeeAlso             = "book.sty",
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\ProvidesClass{mscidl}[2006/29/01]

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% OPTIONS 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% Default options
\LoadClass[12pt,a4paper,oneside]{book}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% PACKAGES
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\RequirePackage[left=3cm,right=2cm,top=2.5cm,bottom=2.7cm,papersize={21.00cm,29.70cm}]{geometry}
% \usepackage[top=2.5cm,bottom=1.5cm,left=3cm,right=2cm,papersize={21.00cm,29.70cm},includehead=false]{geometry}
\RequirePackage{amsmath,amsfonts,amssymb,amsthm}
\RequirePackage[english]{babel} %English instead of [portuges,babel]
                                %to enable english titles to list of
                                %tables, list of figures and acronyms.
%\RequirePackage[latin1]{inputenc}   
\RequirePackage[utf8]{inputenc} %Enables the use of accents.   
\RequirePackage[T1]{fontenc}
\RequirePackage{calc}
\RequirePackage{ifthen}
\RequirePackage{textcase}
\RequirePackage{textcomp}
%\RequirePackage{lmodern}
\RequirePackage{pslatex} %replace by pdffonts
%\allsectionsfont{\rmfamily}
\RequirePackage{graphicx}
\RequirePackage{color}
\RequirePackage{array} % use m{} alignment in tabular
\RequirePackage{setspace} % \onehalfspace
\RequirePackage{soul} % text highlight
\RequirePackage{fancyhdr}
\RequirePackage{afterpage}
\RequirePackage[noend]{algpseudocode}
\RequirePackage{multirow}
\RequirePackage[acronym,nonumberlist]{glossaries} %List of acronyms without
% page reference
\RequirePackage{bm} % permits greek letters in bold face
%\RequirePackage{amsbsy}
\RequirePackage{rotating} % permits tables in landscape
\RequirePackage{booktabs}
\RequirePackage[noend]{algpseudocode}
\RequirePackage[noprefix]{nomencl}






%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% MY ENVIRONMENTS...
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\newenvironment{shrinkwidth}
               {\list{}{\listparindent 1.5em%
                        \itemindent    \listparindent
                        \rightmargin   \leftmargin
                        \parsep        \z@ \@plus\p@}%
                \item\relax}
               {\endlist}

\renewenvironment{thebibliography}[1]
     {\chapter*{\bibname}%
      \@mkboth{{\small \itshape \sffamily References}}{}%
      \list{\@biblabel{\@arabic\c@enumiv}}%
           {\settowidth\labelwidth{\@biblabel{#1}}%
            \leftmargin\labelwidth
            \advance\leftmargin\labelsep
            \@openbib@code
            \usecounter{enumiv}%
            \let\p@enumiv\@empty
            \renewcommand\theenumiv{\@arabic\c@enumiv}}%
      \sloppy
      \clubpenalty4000
      \@clubpenalty \clubpenalty
      \widowpenalty4000%
      \sfcode`\.\@m}
     {\def\@noitemerr
       {\@latex@warning{Empty `thebibliography' environment}}%
      \endlist}
					
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Headers & footers
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\setlength{\headheight}{15pt}
% 
\pagestyle{fancyplain}
% \renewcommand{\chaptermark}[1]{\markboth{#1}{}}
% \renewcommand{\chaptermark}[1]{\markboth{#1}{}}
% 
\lhead{\fancyplain{}{\leftmark}}
\chead{}
\rhead{\fancyplain{}{\rightmark}}
\lfoot{}
\cfoot{\thepage}
\rfoot{}
\renewcommand{\headrulewidth}{0.2pt}
\newcommand{\ClearHeadRule}{\renewcommand{\headrulewidth}{0pt}}
\newcommand{\RestoreHeadRule}{\renewcommand{\headrulewidth}{0.2pt}}

\def\chaptermark#1{ \markboth {{\sffamily \itshape \small
      Chapter~\thechapter}}% Capítulo~\thechapter}}%
  {{\sffamily \small \MakeTextUppercase{#1}}} }

\def\anexomark#1{
   \markboth
	   {{\sffamily \itshape \small Anexo~\arabic{anexo}}}%
      {{\sffamily \small \MakeTextUppercase{#1}}}
}




%\def\schaptermark#1{}
%\def\schaptermark{}
\def\schaptermark#1{\markboth{}{}}
%\def\schaptermark#1{ \markboth {{}}% Capítulo~\thechapter}}%
%  {{\sffamily \small \MakeTextUppercase{#1}}} }
%{\markboth{\normalfont\footnotesize\MakeTextUppercase{#1}}%
%{\normalfont\scriptsize\MakeTextUppercase{#1}}}

\def\sectionmark#1{}
%{\markright{\normalfont\footnotesize\MakeTextUppercase{\thesection\ #1}}}

%\def\chaptermark#1{\markboth{\sc\MakeLowercase{#1}}{\sc\MakeLowercase{#1}}}
%\def\sectionmark#1{\markright{\sc\MakeLowercase{\thesection\ #1}}}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% TABLE OF CONTENTS
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\setcounter{tocdepth}{4}					
					
\renewcommand\tableofcontents{%
  \chapter*{\contentsname}
  \@starttoc{toc}}

\def\l@part#1#2{%
  \ifnum \c@tocdepth >-2\relax
    \addpenalty{-\@highpenalty}%
    \addvspace{2.25em \@plus\p@}%
    \setlength\@tempdima{3em}%
    \begingroup
      \parindent \z@ \rightskip \@pnumwidth
      \parfillskip -\@pnumwidth
      {\leavevmode
       \large\sf\bfseries #1\hfil \hb@xt@\@pnumwidth{\hss}}\par
       \nobreak
         \global\@nobreaktrue
         \everypar{\global\@nobreakfalse\everypar{}}%
    \endgroup
  \fi}
  
\def\l@chapter#1#2{%
  \ifnum \c@tocdepth >\m@ne
    \addpenalty{-\@highpenalty}%
    \vskip 1.0em \@plus\p@
    \setlength\@tempdima{1.5em}%
    \begingroup
      \parindent \z@ \rightskip \@pnumwidth
      \parfillskip -\@pnumwidth
      \leavevmode %\sffamily\bfseries
      \advance\leftskip\@tempdima
      \hskip -\leftskip
      %\vskip .1\baselineskip
	  {\sffamily\bfseries #1}\nobreak\hfil \nobreak\hb@xt@\@pnumwidth{\hss #2}\par
	  \vskip .6\baselineskip
      \penalty\@highpenalty
    \endgroup
  \fi}
  
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Sectioning
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\setcounter{secnumdepth}{4}

% \part
\def\part{
   \if@openright\cleardoublepage\else\clearpage\fi
   \thispagestyle{empty}%
   \secdef\@part\@spart
}
  
% \@part
\def\@part[#1]#2{
   \ifnum \c@secnumdepth >-2\relax
      \refstepcounter{part}
      \addcontentsline{toc}{part}{\thepart\hspace{1em}#1}
   \else
      \addcontentsline{toc}{part}{#1}
   \fi
   %\markboth{}{}
   {
	   \centering
      \interlinepenalty \@M
      \normalfont
      \null\vfil
      \ifnum \c@secnumdepth >-2\relax
         \Large \sf \MakeTextUppercase{\partname\nobreakspace\thepart}
         \par
         \vskip 20\p@
      \fi
      \huge\bfseries\MakeTextUppercase{#2}\par
	}
   \vfil
}

% \@spart
\def\@spart#1{
   {
      \centering
      \interlinepenalty \@M
      \normalfont
      \null\vfil
      \huge\sf\bfseries\MakeTextUppercase{#1}\par
	}
   \vfil
}  

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% CHAPTER INFRA STRUCTURE
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% \chapter
\def\chapter{
   \if
	   @openright
		\cleardoublepage
	\else
	   \clearpage
	\fi %
   \thispagestyle{plain} %
   \global\@topnum\z@ %
   %\@afterindentfalse %
	\@afterindenttrue
   \secdef\@chapter\@schapter %
}

% unstarred \@chapter (e.g. \chapter{Introduction})
\def\@chapter[#1]#2{
   \refstepcounter{chapter} 
   %\addcontentsline{toc}{chapter}{\chaptername~\thechapter \,\, \MakeTextUppercase{#1}} 
   \addcontentsline{toc}{chapter}{\thechapter \,\, \MakeTextUppercase{#1}} 
   \chaptermark{#1} 
   \addtocontents{lof}{\protect\addvspace{10\p@}} 
   \addtocontents{lot}{\protect\addvspace{10\p@}} 
   \relax
   \@makechapterhead{#2} 
   \@afterheading
}

% unstarred \@makechapterhead
\def\@makechapterhead#1{
  {
     \noindent
     \sffamily
	  \itshape
	  \bfseries
     \Large
     \thechapter \,\,\, \MakeTextUppercase{#1}
  }
  \vskip 1.5\baselineskip
}

% starred \@schapter (e.g. \chapter*{Introduction})
\def\@schapter#1{ 
   \schaptermark{#1} 
   \@makeschapterhead{#1} 
   \@afterheading 
}

% starred \@makeschapterhead
\def\@makeschapterhead#1{
   { 
      \noindent 
      \sffamily
		\itshape
 	   \bfseries
      \Large
      \MakeTextUppercase{#1} 
   } 
	\vskip 1.5\baselineskip 
}
					
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% ANEXO
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\newcounter{anexo}

% \chapter
\def\anexo{
   \if
	   @openright
		\cleardoublepage
	\else
	   \clearpage
	\fi %
   \thispagestyle{plain} %
   \global\@topnum\z@ %
   %\@afterindentfalse %
	\@afterindenttrue
   \secdef\@anexo\@sanexo %
}

% unstarred \@chapter (e.g. \chapter{Introduction})
\def\@anexo[#1]#2{
   \refstepcounter{anexo} % 
	% use the same type as "chapter" this is defined in \l@chapter
   \addcontentsline{toc}{chapter}{Anexo~\arabic{anexo} \,\, \MakeTextUppercase{#1}} 
   \anexomark{#1} 
   \addtocontents{lof}{\protect\addvspace{10\p@}} 
   \addtocontents{lot}{\protect\addvspace{10\p@}} 
   \relax
   \@makeanexohead{#2} 
   \@afterheading
}

% unstarred \@makechapterhead
\def\@makeanexohead#1{
  {
     \noindent
     \sffamily
	  \itshape
	  \bfseries
     \Large
     Anexo~\arabic{anexo} \par \noindent \MakeTextUppercase{#1}
  }
  \vskip 1.5\baselineskip
}

% starred \@schapter (e.g. \chapter*{Introduction})
\def\@sanexo#1{ 
   \chaptermark{#1} 
   \@makesanexohead{#1} 
   \@afterheading 
}

% starred \@makeschapterhead
\def\@makesanexohead#1{
   { 
      \noindent 
      \sffamily
		\itshape
 	   \bfseries
      \Large
      #1 
   } 
	\vskip 1.5\baselineskip 
}					
			
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% SECTION
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% \@startsection
\def\@startsection#1#2#3#4#5#6{
   \if@noskipsec \leavevmode \fi
   \par \@tempskipa #4\relax
   %\@afterindentfalse
	\@afterindenttrue
   \ifdim \@tempskipa <\z@ \@tempskipa -\@tempskipa \@afterindentfalse\fi
   \if@nobreak 
	   \everypar{}
	\else
      \addpenalty\@secpenalty\addvspace\@tempskipa
	\fi
   \@ifstar
	   {\@dblarg{\@sect{#1}{\@m}{#3}{#4}{#5}{#6}}}
      {\@dblarg{\@sect{#1}{#2}{#3}{#4}{#5}{#6}}}
}

\def\section{%
   \@startsection{section}{1}{0mm}{\baselineskip}
   {.625\baselineskip}{\sffamily\bfseries\large}
}

\def\subsection{%
  \@startsection{subsection}{2}{0mm}{\baselineskip}
    {.6\baselineskip}{\sffamily\large}}

\def\subsubsection{%
  \@startsection{subsubsection}{3}{0mm}{\baselineskip}
   {.6\baselineskip}{\rmfamily\large}}
	
\def\paragraph{%
  \@startsection{paragraph}{4}{0mm}{\baselineskip}
   {-1em}{\itshape}}


\newcommand*\l@bibliografia[2]{%
  \ifnum \c@tocdepth >\m@ne
    \addpenalty{-\@highpenalty}%
	 % increase the jump from 1 to 3
    \vskip 2.0em \@plus\p@
    \setlength\@tempdima{1.5em}%
    \begingroup
      \parindent \z@ \rightskip \@pnumwidth
      \parfillskip -\@pnumwidth
      \leavevmode 
      \advance\leftskip\@tempdima
      \hskip -\leftskip
      {\bfseries \sffamily #1}\nobreak\hfil \nobreak\hb@xt@\@pnumwidth{\hss #2}\par
      \penalty\@highpenalty
    \endgroup
	 \vskip 0.5em
  \fi}
	

\endinput
